<!doctype html>

<!-- HTML5 Boilerplate -->
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html LastUpdateDateclass="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"><!--<![endif]-->

<head>
<meta charset="utf-8">

<title>Maxis Bill Delivery (Step 1)</title>

<meta name="description" content="" />
<meta name="author" content="" />
<meta name="HandheldFriendly" content="True" />
<meta name="MobileOptimized" content="320" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="cleartype" content="on" />
<link rel="stylesheet" href="css/master.css">

<script src="js/modernizr-2.5.3-respond-1.1.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.8.2.min.js"><\/script>')</script>

<link rel="shortcut icon" href="/favicon.ico">

</head>

<body class="clearfix" onload="iframeResizePipe()" style="background:transparent;">

<iframe id="helpframe" src='' height='0' width='0' frameborder='0'></iframe>

<%
/**
 *  @author Lue
 *  Date : 2002-10-10
 *  Description : Bill Listing for customer
 */

    final String pageTitle = "List Of Bills";
    final String pageTitleEN = "LIST OF BILLS";
    final String pageTitleBM = "";
%>

<%@ page import="com.checkfree.isolutions.customer.persist.*" %>
<%@ page import="com.checkfree.isolutions.statement.*" %>
<%@ page import="com.checkfree.isolutions.statement.persist.*" %>
<%@ page import="com.myebills.ebpsfrontend.cust.utils.*" %>
<%@ page import="com.myebills.ebpsfrontend.cust.controller.*" %>
<%@ page import="com.checkfree.isolutions.property.Properties" %>
<%@ page import="com.checkfree.isolutions.property.PropertiesConfig" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.text.*" %>


<%
  
    // Provide access to decrypted (and plain-text) URL request parameters.
    final EbppxUrlManager urlManager = (EbppxUrlManager) request.getAttribute(EbppxUrlManager.REQUEST_ATTRIBUTE_NAME);

    final String randomKey = (String) session.getAttribute(EbppxConstants.RANDOM_KEY);

	Properties appCfg = PropertiesConfig.getApplicationSettings();

    String strEBPSPaymentOffline= appCfg.getProperty("EBPSPaymentOffline");
    String strEBPSPaymentOfflineMsg= appCfg.getProperty("EBPSPaymentOfflineMsg");
  

    String BILL_DELIVERY_OPTIONS_SERVLET_URL=EbppxCusConstants.BILL_DELIVERY_OPTIONS;
        BILL_DELIVERY_OPTIONS_SERVLET_URL = BILL_DELIVERY_OPTIONS_SERVLET_URL + EbppxUtil.getVersion(BILL_DELIVERY_OPTIONS_SERVLET_URL);

    String CONFIRM_BILL_DELIVERY_SERVLET_URL=EbppxCusConstants.CONFIRM_BILL_DELIVERY;
        CONFIRM_BILL_DELIVERY_SERVLET_URL = CONFIRM_BILL_DELIVERY_SERVLET_URL + EbppxUtil.getVersion(CONFIRM_BILL_DELIVERY_SERVLET_URL);

    final String DATE_FORMAT= EbppxConstants.DATE_FORMAT;
    final String LAST_VIEW_DATE_FORMAT="EEE MMM dd HH:mm:ss z yyyy";
    final DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    final String lastUrl = "";
    final int pageType = 1;
    final String acctSel = "";
    String strLastModifyDate="";
  


    //index of the vector for the selected account
    int selectedAccIndex=-1;

    // Fetch the list of accounts for this user.
    final String selectedAccNo = EbppxUtil.nullToEmpty((String)request.getAttribute("accNo"));
    final Vector cfiAcctExtKeys = (Vector) request.getAttribute("acctExtKeys");

    EbppxAcctDetailsDataBean acctDataBean = (EbppxAcctDetailsDataBean)request.getAttribute(EbppxConstants.ACCT_DETAILS);
    String ack = (String)request.getAttribute(EbppxConstants.SELFCARE_ACKNOWLEDGEMENT);
     String  vEmailSubscriptionDb=acctDataBean.getEmailSubscription();
   

    String emailDb=acctDataBean.getEmailAdd();
   
    Date dateModifyDate =acctDataBean.getLastModifyDate();
	System.out.println("dateModifyDate :"+dateModifyDate);
 	if (dateModifyDate != null) {
 		strLastModifyDate = df.format(dateModifyDate);
     } 


    Account cfiAccount = (Account)request.getAttribute("accObj");

    Vector cfiAccounts = (Vector) request.getAttribute(EbppxConstants.CFI_ACCOUNTS);
    Vector cfiStatements = null;
    Enumeration enumStatements = null;


    SimpleDateFormat lastViewDateFormat = new SimpleDateFormat(LAST_VIEW_DATE_FORMAT);
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);

    //Get the statement vector if an account has been selected
    if ( !selectedAccNo.equals("") && request.getAttribute(EbppxConstants.CFI_STATEMENTS) !=null)
    {
        cfiStatements = (Vector) request.getAttribute(EbppxConstants.CFI_STATEMENTS);
         enumStatements = cfiStatements.elements();
    }
	
	/* final EbppxEcsUser ecsUser = (EbppxEcsUser) session.getAttribute(EbppxConstants.ECS_USER);
    String usr = ecsUser.getUserId(); */
    String strLastUpdateDate = "";

/* 	try{
		Merchant aMerchant = MerchantHomeImpl.singleton().findByName(ecsUser.getMerchantName());

		User cfiUser = UserHomeImpl.singleton().findByLogonIdAndMerchant(ecsUser.getUserId(),aMerchant);
			if(cfiUser != null){
				//strLastUpdateDate = acctDataBean.getLastModifyDate();
				//cfiUser.getProperty("LastUpdateDate");
			}
    }catch (Throwable t){
        throw new ServletException(t.toString(), t);
    } */
	
	if(selectedAccNo!=null && !selectedAccNo.equals("")){
					boolean boolXPhysicalBillSubscription = false;
					boolean boolEBillSubscription = false;
					boolean boolTNC = false;
					boolean bool010 = false;
					boolean bool011 = false;
					boolean bool012 = false;
					boolean bool013 = false;
					boolean bool014 = false;
					boolean bool016 = false;
					boolean bool017 = false;
					boolean bool018 = false;
					boolean bool019 = false;


					String strEMailAdd="",strSMSNo="",strAcctSubscription="",strEmailSubscription="",strSMSSubscription="",strPreFix="";

					
					strEMailAdd = acctDataBean.getEmailAdd();
					strSMSNo = acctDataBean.getSMSNo();

				
					strEmailSubscription = acctDataBean.getEmailSubscription();
					strSMSSubscription = acctDataBean.getSMSSubscription();

					bool010 = false;
					bool011 = false;
					bool012 = false;
					bool013 = false;
					bool014 = false;
					bool016 = false;
					bool017 = false;
					bool018 = false;
					bool019 = false;

					if(strSMSNo!=null && !strSMSNo.equals("")){
						strPreFix = strSMSNo.substring(2,4);
						if(strPreFix.equals("12")){
							bool012 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("10")){
							bool010 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("11")){
							bool011 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("13")){
							bool013 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("14")){
							bool014 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("16")){
							bool016 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("17")){
							bool017 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("18")){
							bool018 = true;
							strSMSNo = strSMSNo.substring(4);
						}else if(strPreFix.equals("19")){
							bool019 = true;
							strSMSNo = strSMSNo.substring(4);
						}
					}


					boolean boolNotifySMSNo = false;
					boolean boolBillEMail = false;
					boolean boolAccount = false;
                    boolean boolEmail = false;
                 
					if(strEmailSubscription.equals("1") || strEmailSubscription.equals("P")){
						boolBillEMail = true;
						
					}
					if(strSMSSubscription.equals("1")){
						boolNotifySMSNo = true;
					}
					if(strEmailSubscription.equals("P")){	
						boolEmail =true;
					}
					

%>


<script type="text/javascript">
  function iframeResizePipe()
  {
     // What's the page height?
     //var height = document.body.scrollHeight;
	 var height = document.documentElement.scrollHeight;

     // Going to 'pipe' the data to the parent through the helpframe..
     var pipe = document.getElementById('helpframe');

     // Cachebuster a precaution here to stop browser caching interfering
	 pipe.src = 'http://10.21.10.34/content/dam/maxis/html/helper.html?height='+height+'&cacheb='+Math.random();
	 //pipe.src = 'https://new.maxis.com.my/content/dam/maxis/html/helper.html?height='+height+'&cacheb='+Math.random();
     //pipe.src = 'http://maxis-stage-web.xm-apac.com/content/dam/html/helper.html?height='+height+'&cacheb='+Math.random();
     //pipe.src = 'https://www.maxis.com.my/content/dam/maxis/html/helper.html?height='+height+'&cacheb='+Math.random();
  }
</script>
<script language="javascript" src="js_functions.js"></script>
<script language="javascript">

 
 function ebillCheckbox() {
	/* var vAcctSubscription = document.getElementById('vAcctSubscription'); */
	//var vEmailSubscription = document.getElementById('vEmailSubscription').checked;
	//var EMailAdd = document.getElementById("EMailAdd");
	//var EmailAdd2 = document.getElementById("EMailAdd2");
   
/* 	if (vEmailSubscription) {
	
		vAcctSubscription.checked = false;
		//EMailAdd.style.display = '';
		//EmailAdd2.disabled = false;
	}  */
	

}  

  function autotab(original,destination) {
	if (original.getAttribute && original.value.length == original.getAttribute("maxlength")){
		destination.focus();
	}
  }

function checkData(frm){
	
	//var acctSubscription = document.getElementById('vAcctSubscription').checked;
	//var emailSubscription = document.getElementById('vEmailSubscription').checked;
    
	var emailSubscription = frm.emailDeliverySubscription.checked;
	/* var acctSubscription = frm.billSupressSubscription.checked; */
	var sMSSubscription = frm.smsNotificationSubscription.checked;
	var vEmailSubscriptionOld='<%=vEmailSubscriptionDb%>';
    var emailOld='<%=emailDb%>'; 
    <%-- var vAccountSubscriptionOld='<%=vAccountSubscription%>';
      --%>
    var emailNew=frm.emailAdd.value;
  
   /*  if(acctSubscription == true){
    	acctSubscription = 1;
    } */
    if(emailSubscription == true){
    	emailSubscription = 1;
    }
    
	$("#numberError").text("");
	$("#emailError").text("");
	$("#TNCError").text("");
	// SMS no checking
   
	if(frm.smsNotificationSubscription.checked){
		if(frm.mobileNo.value==""){
			$("#numberError").text("Please enter the SMS No");
			frm.mobileNo.focus();
			return false;
		}else{
			var x = frm.mobileNo.value;
			if(!IsBlank(x)){
			  if(!IsNumber(x)){
				$("#numberError").text("The SMS number must be a number.Please enter again");
				frm.mobileNo.focus();
				return false;
			  }else if(x.length<7){
				$("#numberError").text("The SMS number must be at least 7 digits. Please enter again");
				frm.mobileNo.focus();
				return false;
			  }
			}
		
		}
		if(frm.prefix.value==""){
			$("#numberError").text("Please enter the prefix No");
			frm.prefix.focus();
			return false;
		}else{
			var x = frm.prefix.value;
			if(!IsBlank(x)){
			  if(!IsNumber(x)){
				$("#numberError").text("The prefix number must be a number.Please enter again");
				frm.prefix.focus();
				return false;
			  }else if(x.length<3){
				$("#numberError").text("The prefix number must be at least 3 digits. Please enter again");
				frm.prefix.focus();
				return false;
			  }
			}
		}
	}
	
	// Email address checking
	if(emailSubscription == true){
		if(frm.emailAdd.value==""){
			
			$("#emailError").text("Please enter the bill delivery email address.");
			frm.emailAdd.focus();
			return false;
			
		}else{
		
			var x = frm.emailAdd.value;
			if(!IsBlank(x)){
				if(!IsEmail(x)){
				  $("#emailError").text("This is not a valid email address.Please enter again.");
				  frm.emailAdd.focus();
				  return false;
				}
			}
		}
	}
	//for email change 
  /*  if(!(emailOld == emailNew)){
     if(!(emailSubscription == true)){
		  $("#emailSubscriptionError").text("There was a change of your e-mail address .Please subscription email delivery for verification");
		  frm.emailDeliverySubcription.focus();
		  return false;
     }
    } 
	   */
	  
 	if(!(emailOld==emailNew) && (emailSubscription==false) && !(emailNew==null)){
		$("#emailSubscriptionError").text("Please subscribe send my bill via email.");
		frm.emailDeliverySubcription.focus();
		return false;
		
	} 
	/* if((vEmailSubscriptionOld==emailSubscription) && (acctSubscription ==vAccountSubscriptionOld) && (emailOld ==emailNew)){
		
			$("#subscriptionError").text("There have no any change on this page.");
			frm.emailAdd.focus();
			return false;
	} */
		
	// Check on agreeing tnc if suppress/email delivery checkbox is checked
	if(emailSubscription && frm.tnc.checked==false){
		$("#TNCError").text("Kindly check the agreement box to subscribe to bill via email.");
		frm.tnc.focus();
		return false;
	}
	/* if(acctSubscription && frm.tnc.checked==false){
		$("#TNCError").text("Kindly check the agreement box if you don't wish to receive bill via post.");
		frm.tnc.focus();
		return false;
	} */

	//return true;
    frm.submit();
}

function showHideEmail() {
	var vEmailSubscription = document.getElementById("vEmailSubscription");
	//var EMailAdd = document.getElementById("textfield");
	var EmailAdd2 = document.getElementById("textfield");

	if (vEmailSubscription.checked) {
		//EMailAdd.style.display = '';
		EmailAdd2.disabled = false;
	} else {
		//EMailAdd.style.display = 'none';
		EmailAdd2.disabled = true;
	}

}

  function IsBlank(expression){
    if(Trim(expression)==""){
      return true;
    }else{
      return false;
    }
  }
  function IsComma(expression){
    if(expression.indexOf(",")!="-1"){
      return false;
    }else{
      return true;
    }
  }
</script>


    
<div class="delivery_form">
	<hr class="hr_dashed" />
	<form class="delivery_option" name="delivery_option" id="delivery_option" method="post" action="<%=CONFIRM_BILL_DELIVERY_SERVLET_URL%>">

<%
System.out.println("********************************************Bill delivery 8");
	if(strLastModifyDate!=null && !strLastModifyDate.equals("")){
%>
       
		<p><span id="lastupdate">Your last update was <em><%=strLastModifyDate%>.</em></span></p>
<%}%>
		<input type="hidden" name="accNo" value="<%=selectedAccNo%>">
		<%-- <p><input type="radio" class="checkbox" value="1"  id="vAcctSubscription" name="billSupressSubscription"   <%if(boolAccount)out.println(" checked");%> onClick="physicalCheckbox()"/><span> Physical bill<span> <!-- <span>Don't send my bill via Post <em>(waive itemised bill charge)</em></span> --></p>
		<p><span class="error" id="CHECKBOXError"></span></p> --%>
		<p><input type="checkbox" class="checkbox" value="P"  id="vEmailSubscription" name="emailDeliverySubscription" <%if(boolBillEMail)out.println(" checked");%><span>Send my bill via Email</span></p>
		<p><span class="error" id="emailSubscriptionError"></span></p>
		<p><input type="checkbox" class="checkbox" value="1" name="smsNotificationSubscription" <%if(boolNotifySMSNo)out.println("checked");%> /> <span>Send my bill notification via SMS <em>(optional)</em></span></p>
		<p><span class="error" id="CHECKBOXError"></span></p>
		<p><input type="checkbox" class="checkbox" name="tnc" <%if(boolTNC)out.println(" checked");%> /> <span>I have read this <a href="#" class="click_notice">Notice</a> <em>(you must check this to get your chosen bill delivery options)</em></span></p>
		<p><span class="error" id="TNCError"></span></p>
		<p><span class="error" id="subscriptionError"></span></p>
		<div class="marginauto width80">
		   
			<p><label>My Email <font color="red"></font></label><input type="text" name="emailAdd" id="textfield" value="<%=strEMailAdd%>"/><br/><span class="error"  id="emailError"><br/>
					
			 </span></p> 
			
		    <span class="error2" id="emailError2"><%if((boolEmail) &&(session.getAttribute(EbppxConstants.EBILL_REGISTER_FLAG2)=="true"))out.println("Status : Pending for email verification");%></span>
	    </div>
	    <div class="marginauto width67">
			 <span class="error2" id="emailError3"><%if(session.getAttribute(EbppxConstants.EBILL_REGISTER_FLAG)=="true")out.println("Thank you for your request. We have sent a verification email to your email address. Kindly check your email and follow the instruction to complete your request. The E-bill service will be activated after you have completed the verification.");%></span>
       </div>
       <div class="marginauto width80">
			<p><label>My Mobile No</label><select name="prefix"><option <% if(bool010)out.println("selected");%> value=6010>010</option><option <% if(bool011)out.println("selected");%> value=6011>011</option><option <% if(bool012)out.println("selected");%> value=6012>012</option><option <% if(bool013)out.println("selected");%> value=6013>013</option><option <% if(bool014)out.println("selected");%> value=6014>014</option><option <% if(bool016)out.println("selected");%> value=6016>016</option><option <% if(bool017)out.println("selected");%> value=6017>017</option><option <% if(bool018)out.println("selected");%> value=6018>018</option><option <% if(bool019)out.println("selected");%> value=6019>019</option></select>&nbsp;&nbsp;<input class="medium" type="text" name="mobileNo" id="mobileNo" value="<%=strSMSNo%>" maxlength="8" /><br />
				<span class="error" id="numberError"></span></p>
			
		</div>
		<div class="clear"></div>
		<div class="align-center"><input type="button" class="btn" value="Submit" onclick="return checkData(document.delivery_option)" /></div>
	</form>
</div>


<div class="clear"></div>

<div class="delivery_notice">
	<div class="clear"></div>
	<hr class="hr_dashed" />
	<!-- <p>All request for 'DON'T SEND MY BILL VIA POST' or official bill statement to be sent to your emailing address must be submitted no later than 48 hours before the date of your official bill statement. Request made on or after the date of your official bill statement will be applicable for the following month's official bill statement.</p>
	<p>In the event you do not receive your official bill statement, please:</p>
	<ol>
		<li>Log on to Maxis Online Account website and view your official bill statement on-line; or.</li>
		<li>Contact our Customer Service at 1800 821 123 or dial 123 from your Maxis mobile for assistance. If you are abroad, dial +603 749 22123.</li>
		<li>I / We hereby agrees that this service subscribed herein shall form part of the Services ( as defined in the Agreement ) and further agree to be bound by the terms and conditions of the Agreement</li>
	</ol> -->
	<p>1. E-Bill (bill to be sent via your email address) request must be submitted no later than 48 hours before the date of the official bill statement.
	<p>2. Request made on or after the date of your official bill statement will be applicable for the following month's official bill statement.
	<p>3. No bill will be sent via post. Please perform verification via your email address within 5 days upon your E-Bill service request.
	<p>4. I / We hereby agree that this service subscribed herein shall form part of the Services (as defines in the Agreement) and further agree to be bound by the terms and conditions of the Agreement.
	<div class="align-center"><input type="button" class="btn close_notice" value="Back" /></div>
</div>

<%}%>

<script type="text/javascript">
	$(document).ready(function() {
		
		//account info accordian
		$('.account_info ul li ul span.expand').click(function(){
			$('.account_info ul li ul li').slideUp();
			$(this).next().slideDown();
			$('.account_info ul li ul li ul li').show();
		});
		
		//show notice
		$('.click_notice').click(function(){
			$('.delivery_form').slideUp();
			$('.delivery_notice').slideDown();
			return false;
		});
		
		//hide notice
		$('.close_notice').click(function(){
			$('.delivery_notice').slideUp();
			$('.delivery_form').slideDown();
			return false;
		});
		
		$(".delivery_option").bind("submit", function() {
			$.ajax({
				type		: "POST",
				cache	: false,
				url		: "includes/submit_delivery.php",
				data		: $(this).serializeArray(),
				success: function(data) {
					$.fancybox(
						'<div class="delivery_error">'+data+'<input type="button" value="OK" class="btn" onclick="$.fancybox.close();" /></div>',
						{
							'closeBtn'	: false
						}
					);
				}
			});

			return false;
		});
		
		/*$("#submitbtn").click( function (event) {
			$form = $("#delivery_option");
			console.log($form.serialize());
			if(checkData(document.delivery_option)){
				$.ajax({
						beforeSubmit: $.fancybox.showLoading(),
						url: $form.attr("action"),
						type: $form.attr("method"),
						dataType: 'html',
						data: $form.serialize(),
						success: function(data) {
							$.fancybox(data, {
								width		: 400,
								height		: 500,
								fitToView	: true,
								autoSize	: true,
								closeClick	: false,
								openEffect	: 'fade',
								closeEffect	: 'fade',
								padding		: 0
							});
						},
						error: function (xhr, ajaxOptions, thrownError) {
						console.log('Error!  Status = ' + xhr.status );
							$.fancybox("Failed to load resources", {
								width		: 400,
								height		: 500,
								fitToView	: true,
								autoSize	: true,
								closeClick	: false,
								openEffect	: 'fade',
								closeEffect	: 'fade',
								padding		: 0
							});
						}
				});
			}
		});*/
		
	});
</script>

<script src="js/jquery-ui-1.9.2.custom.min.js"></script> 
<script src="js/plugins.js"></script>
<script src="js/helper.js"></script>
<script src="js/jquery.fancybox.js" type="text/javascript"></script>


</body>

<%
	
     session.setAttribute(EbppxConstants.EBILL_REGISTER_FLAG,"");
%>
</html>

